package pack

import (
	"mall_frontend_api/biz/model"
	"mall_frontend_api/biz/model/category"
)

func GetCategoryList(list []*model.Category, pid int64) []*category.Category {
	var data = make([]*category.Category, 0)
	if len(list) == 0 {
		return data
	}

	for _, info := range list {
		if info.Pid == pid {
			var t = category.NewCategory()
			t.ID = info.ID
			t.Name = info.Name
			t.Child = GetCategoryList(list, info.ID)
			data = append(data, t)
		}
	}
	return data
}
